package cloud.xlh.digital_power_order.facade.order.impl;

import cloud.xlh.digital_power_order.client.order.dto.GenOrderReqDTO;
import cloud.xlh.digital_power_order.client.order.dto.RefundOrderReqDTO;
import cloud.xlh.digital_power_order.client.order.service.OrderClientService;
import cloud.xlh.digital_power_order.domian.order.OrderSaveDomain;
import cloud.xlh.digital_power_order.domian.order.OrderUpdateDomain;
import cloud.xlh.digital_power_order.intergration.order.adapter.OrderClientAdapter;
import cloud.xlh.digital_power_order.service.order.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2023/8/12 18:08
 * @ Description:
 */
@Service
public class OrderClientServiceImpl implements OrderClientService {
    @Resource
    private OrderClientAdapter orderClientAdapter;
    @Resource
    private OrderService orderService;

    @Override
    public String genOrder(GenOrderReqDTO genOrderReqDTO) {
        OrderSaveDomain orderSaveDomain = orderClientAdapter.convertOrderSaveDomain(genOrderReqDTO);
        return orderService.genOrder(orderSaveDomain);
    }

    @Override
    public String selectOrder(String orderNo) {
        return orderService.selectOrder(orderNo);
    }

    @Override
    public String payOrder(String orderNo) {
        return orderService.payOrder(orderNo);
    }

    @Override
    public String refundOrder(RefundOrderReqDTO refundOrderReqDTO) {
        OrderUpdateDomain orderUpdateDomain = orderClientAdapter.convertOrderUpdateDomain(refundOrderReqDTO);
        return orderService.refundOrder(orderUpdateDomain);
    }

}
